package com.tenebrous.jestic.controller.framwork.system.logs;

import com.github.pagehelper.PageInfo;
import com.tenebrous.jestic.controller.SupperController;
import com.tenebrous.jestic.entity.framwork.system.SysLogLogin;
import com.tenebrous.jestic.service.framwork.system.SysLogService;
import com.rain.ops.sdk.dto.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;


/**
 * 操作日志duanxiang
 */
@Validated
@RestController
@RequestMapping("/log/login")
public class LoginLogController extends SupperController {

    @Autowired
    private SysLogService logService;

    /**
     * 分页查询
     * @return
             */
    @PostMapping("/paging")
    public ApiResult paging(String loginName) {
        PageInfo<SysLogLogin> pageInfo = logService.queryLoginPagingList(super.getPageIndex(), super.getPageSize(), loginName);
        return new ApiResult(200, "查询成功。", pageInfo);
    }
    /**
     * 查看详情
     * @return
     */
    @PostMapping("/get")
    public ApiResult get(@NotBlank String id) {
        SysLogLogin item = logService.selectByPrimaryKey(id);
        if(item != null) {
            return new ApiResult(200, "查询成功。", item);
        }
        return new ApiResult(999, "查询失败，未找到指定对象。");
    }

    /**
     * 查看详情
     * @return
     */
    @PostMapping("/delete")
    public ApiResult delete() {
        return logService.deleteAllLogin();
    }
}
